<?php

namespace app\api\controller;

use app\api\logic\AreaLogic;
use app\api\validate\AreaValidate;
use app\common\controller\Api;

class Area extends Api
{
    protected $noNeedLogin = ['*'];
    protected $noNeedRight = ['*'];

    /**
     * @api {get} /api/area/selectList 省市区列表
     * @return null
     */
    public function selectList()
    {
        $param = [
            'level' => $this->request->get('level'),
            'keyword' => $this->request->get('keyword'),
        ];

        $validate = new AreaValidate();
        if (!$validate->scene('selectList')->check($param)) {
            return $this->error($validate->getError());
        }

        $logic = new AreaLogic();
        $data = $logic->selectList($param);

        return $this->success('success', $data);
    }

}